fix(profiling): Reset shouldStop flag on startProfiler#5284
Open
fix(profiling): Reset shouldStop flag on startProfiler#5284
Conversation
…artProfiler Same fix as PerfettoContinuousProfiler — shouldStop was never reset to false after stopProfiler, so a stop/start cycle would leave shouldStop=true and silently stop the profiler after one chunk. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Bug Fixes 🐛
🤖 This preview updates automatically when you update the PR. |
Contributor
Instructions and example for changelogPlease add an entry to Example: ## Unreleased
### Fixes
- Reset shouldStop flag on startProfiler ([#5284](https://github.com/getsentry/sentry-java/pull/5284))If none of the above apply, you can opt out of this check by adding |
Sentry Build Distribution
|
Contributor
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 889ecea | 367.58 ms | 437.52 ms | 69.94 ms |
| d15471f | 343.13 ms | 361.47 ms | 18.34 ms |
| 9fbb112 | 404.51 ms | 475.65 ms | 71.14 ms |
| 9ea89e8 | 308.06 ms | 358.16 ms | 50.10 ms |
| ee747ae | 415.92 ms | 470.15 ms | 54.23 ms |
| ee747ae | 405.43 ms | 485.70 ms | 80.28 ms |
| a416a65 | 316.52 ms | 359.67 ms | 43.15 ms |
| b193867 | 331.08 ms | 397.06 ms | 65.98 ms |
| 91bb874 | 310.68 ms | 359.24 ms | 48.56 ms |
| 6405ec5 | 310.88 ms | 354.56 ms | 43.69 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 889ecea | 1.58 MiB | 2.11 MiB | 539.75 KiB |
| d15471f | 1.58 MiB | 2.13 MiB | 559.54 KiB |
| 9fbb112 | 1.58 MiB | 2.11 MiB | 539.18 KiB |
| 9ea89e8 | 1.58 MiB | 2.28 MiB | 716.23 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| ee747ae | 1.58 MiB | 2.10 MiB | 530.95 KiB |
| a416a65 | 1.58 MiB | 2.12 MiB | 555.26 KiB |
| b193867 | 1.58 MiB | 2.19 MiB | 620.00 KiB |
| 91bb874 | 1.58 MiB | 2.13 MiB | 559.07 KiB |
| 6405ec5 | 1.58 MiB | 2.12 MiB | 552.23 KiB |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
📜 Description
shouldStopis never reset tofalseafterstopProfiler(), so a stop/start cycle leavesshouldStop=true. When the next 60-second chunk timer fires,stop(restartProfiler=true)checks!shouldStopand does not restart — the profiler silently stops after one chunk instead of continuing indefinitely.This affects both lifecycle modes:
Sentry.startProfiler()→Sentry.stopProfiler()→Sentry.startProfiler()— second session stops after one chunkshouldStop=true) → new transaction starts → profiler starts but stops after one chunkFix: reset
shouldStop = falseat the top ofstartProfiler(), since it represents a new intent to profile.💡 Motivation and Context
Discovered while working on the Perfetto ProfilingManager integration (#5251). The same bug existed in both
AndroidContinuousProfilerandPerfettoContinuousProfiler.💚 How did you test it?
Unit test added:
manual profiler can be started again after a full start-stop cycle— starts profiling, stops it, starts again, verifies the profiler continues running after the first chunk restart.📝 Checklist
sendDefaultPIIis enabled.🔮 Next steps
None — standalone bugfix.